<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="/template.xhtml">

            <ui:define name="content">
                <h:form>
                    <h:outputLabel for="selmnd" value="#{msg.maaned}"/>
                    <h:selectOneMenu id="selmnd" value="#{oktTabell.maaned}">
                        <f:selectItem itemLabel="#{msg.alle}" itemValue="0"/>
                        <f:selectItem itemLabel="#{msg.januar}" itemValue="1"/>
                        <f:selectItem itemLabel="#{msg.februar}" itemValue="2"/>
                        <f:selectItem itemLabel="#{msg.mars}" itemValue="3"/>
                        <f:selectItem itemLabel="#{msg.april}" itemValue="4"/>
                        <f:selectItem itemLabel="#{msg.mai}" itemValue="5"/>
                        <f:selectItem itemLabel="#{msg.juni}" itemValue="6"/>
                        <f:selectItem itemLabel="#{msg.juli}" itemValue="7"/>
                        <f:selectItem itemLabel="#{msg.august}" itemValue="8"/>
                        <f:selectItem itemLabel="#{msg.september}" itemValue="9"/>
                        <f:selectItem itemLabel="#{msg.oktober}" itemValue="10"/>
                        <f:selectItem itemLabel="#{msg.november}" itemValue="11"/>
                        <f:selectItem itemLabel="#{msg.desember}" itemValue="12"/>
                    </h:selectOneMenu>
                    <h:outputLabel for="aar" value="#{msg.aar}"/>
                    <h:inputText id="aar" value="#{oktTabell.aar}" validatorMessage="#{msg.aar_err}">
                        <f:validateLongRange />
                    </h:inputText><hr/>
                    <h:dataTable value="#{oktTabell.tabellData}" var="okt" columnClasses="tabellKolonne,tabellKolonne
                                 ,tabellKolonne,tabellKolonne,tabellKolonne" rendered="#{oktTabell.antall > 0}"
                                 rowClasses="tabellKolonne" styleClass="oktTabell">
                        <h:column>
                            <f:facet name="header">#{msg.dato}</f:facet>
                            <h:inputText id="dato" value="#{okt.data.dato}" required="true"
                                         requiredMessage="#{msg.dato_req}" label="#{msg.dato2}"
                                         validatorMessage="#{msg.dato_err}" valueChangeListener="#{okt.endret}"
                                         converterMessage="#{msg.dato_err}">
                                <f:convertDateTime pattern="dd-MM-yy"/>
                            </h:inputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{msg.kategori}</f:facet>
                            <h:selectOneMenu id="kategori" value="#{okt.data.kategori}" valueChangeListener="#{okt.endret}">

                                <f:selectItems value="#{kategoriFinner.kategorier}" var="k" itemLabel="#{k}" itemValue="#{k}" />
                            </h:selectOneMenu>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{msg.tekst}</f:facet>
                            <h:inputTextarea id="tekst" value="#{okt.data.tekst}" valueChangeListener="#{okt.endret}" required="true"
                                             requiredMessage="#{msg.besk_req}">
                                <f:validateLength maximum="30"/>
                            </h:inputTextarea>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{msg.varighet}</f:facet>
                            <h:inputText id="varighet" value="#{okt.data.varighet}" required="true"
                                         requiredMessage="#{msg.varig_req}" label="#{msg.varighet}"
                                         validatorMessage="#{msg.varig_err}" valueChangeListener="#{okt.endret}"
                                         converterMessage="#{msg.varig_err}">
                                <f:validateLongRange minimum="1" />
                            </h:inputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{msg.skalslettes}</f:facet>
                            <h:selectBooleanCheckbox value="#{okt.slett}"/>
                            <f:facet name="footer">

                            </f:facet>
                        </h:column>

                    </h:dataTable>
                    #{msg.antall}: #{oktTabell.antall}, #{msg.varigavg}: #{oktTabell.gjennomsnittVarighet}
                    <h:commandButton value="#{msg.oppdater}" action="#{oktTabell.oppdater}"/>
                    
                </h:form>
                <h:form>
                    <h:commandButton value="#{msg.nyokt}" action="/okter/nyOkt"/>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
